﻿using B.S.InOut.Domain;
using B.S.InOut.Infacation.Information;

namespace B.S.InOut.Writer.Api.Appcation.Dapper
{
    public class ProductService
    {
        public readonly IBaseRepository<ProductModel> _productRepository;

        public ProductService(IBaseRepository<ProductModel> productRepository)
        {
            _productRepository = productRepository;
        }

        public async Task<int> AddProduct(ProductModel product)
        {
            return await _productRepository.InsertAsync(product);
        }

        public async Task<bool> UpdateProduct(ProductModel product)
        {
            return await _productRepository.UpdateAsync(product);
        }

        public async Task<bool> DeleteProduct(int id)
        {
            return await _productRepository.DeleteAsync(id);
        }

        public async Task<ProductModel> GetProductById(int id)
        {
            return await _productRepository.GetByIdAsync(id);
        }

        public async Task<IEnumerable<ProductModel>> GetAllProducts()
        {
            return await _productRepository.GetAllAsync();
        }
    }
}
